home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Suzy B Software 2
/
Suzy B Software CD-ROM 2 (1994).iso
/
finances
/
checkbal
/
checkbal.doc
< prev
next >
Wrap
Text File
|
1995-04-25
|
20KB
|
545 lines
William Blair
2608 Adela Avenue
Orlando, FL 32826
(305) 277-6432
Check Balancer Program
I had my Atari 8-bit computer for four years, and one of the things I
used it for most often was to balance my checkbook. When I moved up to the
16-bit Atari's, I sold my 8-bitter, much to my later regret. One of the
things I missed most was the program that I had used in balancing my
checkbook, especially since it made what usually was a tedious task into a
simple process.
It soon occurred to me, however, that the ST computer would be even
better for that sort of thing. The GEM interface would definitely make a
program more user-friendly, and the speed-up in sorting and searching would
certainly be a plus. So I took it upon my self to write a checkbook
balancing program of my own. And this is what came from the effort.
The program itself is written in Modula-2, a language designed by the
same person who designed Pascal, Dr. Nickolas Worth. It allows a great
amount of modularity (hence the name) and enables fast development. This is
the first program that I have written on the ST computer, and the first time
I have used Modula-2. Still, I was able to finish the program in about 72
man-hours. This includes initial design, programming and debugging. A very
nice language, Modula-2.
A Note on Dialogs
When entering dollar amounts into the program, you will find that
leading zeros must be entered. I realise that this can get irritating,
however, I chose this method for two good reasons. First of all, I wanted to
use the TOS input routines for the dialogs, so that it would limit the type
of characters to be entered, and would save me from having to write the input
routine myself. It is difficult to intercept the text entered in a dialog,
and I wanted the only characters to be accepted for the amount input to be
numbers. Also, I was trying to save time in writing this program since I had
a (self-imposed) deadline. The second reason for using the TOS input
handling routines is that I wanted to have the decimal point present in the
input area because I thought it improved the look of the dialog. It
shouldn't cause too many problems.
Also, all alphabetic information entered during the dialogs must be
uppercase. It data is entered in lowercase it won't show up on the screen
and this could be confusing. Just make sure that uppercase is enabled before
entering data.
Using the Program
The program was developed to allow the user to enter all withdrawals,
deposits, and checks written on a bank account into a file. The entries are
placed in the file ordered on the date the transaction occurred. The program
allows the entries to be searched using a number of criteria, and also will
assist in balancing the account. These are described in more detail below.
Note that no menu selections are enabled until a file has been loaded, or at
least until a filename has been given and initial file data entered.
This initial file information consists of the user's name, address,
city, state, year, and current amount in bank account. The name and address
information isn't essential and doesn't have to be entered, but it improves
the look of the program. The current bank account balance must be entered,
however. Just get the amount from the last bank statement received.
There is a limit on the greatest value that can be displayed in the
dialogs. This is $99999.99, or for negative numbers, $-9999.99. This is
because I only allowed seven characters for displaying the numbers in the
dialogs. This won't cause any problems for the most part, since few people
have deposits or withdrawal amounts in those quantities. However, if by some
chance such a large number does occur, a message will appear stating that the
number can't be displayed, and the program will continue. Dispite the fact
that the number isn't displayed, it is still valid in memory, and will be
used in the calculations done.
The File Menu
This menu contains the file commands. They are used to load, save, and
delete a file, as well as quit the program.
Load - This is about the only menu selection enabled when the program
first comes up. It is necessary during the first use of the program to use
LOAD so that some program information can be entered. When this is selected,
the program checks to see if there is any valid data in memory. If so, it
asks the user if it is okay to delete the current data before loading a new
file. If the user selects YES, the program deletes the data. Then the user
will be asked for a filename using the standard GEM item selector. Selecting
CANCEL will abort the selection. If a filename is entered, the program
checks to see if the file exists. If it does, the data is loaded into
memory. If not, this is when a dialog box will open that will ask for some
initial data from the user as described above. Clicking on the exit button
will save the information within the program.
Save - This command will save the data currently in memory, then will
return to the program to allow further changes to be entered.
Close - Like SAVE, this command will save the data currently in memory.
However, it also deletes the data in memory to allow a new file to be loaded.
Delete - This command allows a file to be deleted. It asks for
confirmation before executing.
Quit - This command exits the program.
The Entry Menu
This menu has the commands used to enter data about checks, withdrawals,
and deposits into memory. It uses dialogs to help speed things up as well as
make entry easier.
Enter Checks - This command allows the user to enter checks. It opens a
dialog which looks similar to a check form, and allows entry of date, check
number, payee, check amount, and a short memo line. Clicking on the "Enter
Check" button will enter the data into memory and allow a new check to be
entered. The check number will be automatically incremented each time.
After all checks have been entered, clicking on the "Quit" button will exit
the check form.
Enter Withdrawals - This command allows the entering of all withdrawals
that are not checks. It allows entry of date, withdrawal amount and a short
memo line. As above, clicking on the "Enter Entry" button will enter the
data into memory, while clicking on the "Quit" button will exit the form.
Enter Deposits - This is similar to the "Enter Withdrawals" form but is
used for deposits into a bank account.
Make New Year File - This command is used at the end of the current year
to build a file for the next year containing all the entries that hadn't been
cancelled. It also carries over the name, address, current balance, and
increments the year. This allows the user to avoid having to re-enter this
information at the end of a year. This command will delete the entries
currently in memory during the search, so make sure any new entries have been
saved before using it. A message will come up to insure this has been done.
Note that after the user exits a form, a dialog will come up showing the
current balance left in the account after the checks, withdrawals, and
deposits have been entered. This dialog is exited by clicking on the "Okay"
button. If the current balance is too large to be displayed within the seven
character limitation, an error dialog will come up instead.
The Search Menu
This menu allows the user to define parameters for searching and
printing, and to search and print using those parameters. As noted above, all
data must be entered in uppercase.
Enter Parameters - This command opens a dialog that will allow the user
to specify an number of search criteria. These will allow searching and
printing based on date, check number, payee (or substring thereof), amount,
and memo (or substring thereof). The data is checked for validity after the
dialog is exited by clicking the "Okay" button.
When the dialog first comes up, there will be default values for each of
the search criteria. If the user wishes to return to these default values
after they have been modified, all that is necessary is to press the escape
key for that entry. When the dialog is exited, it will place the default
values in any entry that it finds empty. This is necessary for the payee and
memo string searches since the default is "All", and this can't be entered
from the keyboard since it contains lowercase letters.
Search Entries - When this command is selected, the program will ask if
the user wishes the include the withdrawal and deposit entries in the search.
This is so a user that wishes to see data relating to checks only can do so.
The program will then search the list of entries using the parameters
specified in the above command. A "Searching" message will show on the
screen during the search process. After all entries have been located that
match the search criteria, a window will open to display the first entry. To
examine the entries, simply click the up and down arrows of the window, and
the entries will be displayed one by one. The search command can be exited
by closing the window.
Note that when the window is open the Options menu selections become
enabled. These will allow the entry in the window to be deleted, cancelled,
or edited. More information on how these are used can be found below.
Print Entries - This command will print the list of entries that match
the search parameters. A "Searching" message will display during the search
process, then the program will start printing the entries. This is a simple
routine that doesn't allow the print format to be modified. It simply allows
the user to make a printout of his entries for his records.
The printing can be stopped any time by hitting any key. This will stop
the printing and return control to the program. Also, if an error occurs
with the printer, the program will stop and display an error message to the
user.
The Review Menu
This menu contains the commands that are used to balance the checkbook.
Review Entries - This command will open a window that will allow the
user to review the entries in memory. The entries can be displayed forward
and backward as in the search window by clicking the up and down arrows of
the window. The entries can also be reviewed by clicking the left and right
arrows of the window. This will display the entry that begins the next
month. For example, if an entry for January is displayed in the window,
clicking on the right arrow will skip over all entries until it finds the
first entry of the next month, which is February. If there is no entry for
February, it will display the first entry for the month of March, and so on.
This allows a speedy method of skipping to the end of the year, or jumping
over many of entries at a time.
As above, this command will enable the selections in the Options menu,
and will allow the user to delete, cancel, or edit the entry currently
displayed in the window. The command is exited by closing the window.
Figure Balance - This command will determine if the entries stored in
memory, and the entries on the bank statement match. It will first ask for
the current balance that is shown on the bank statement. Then it will
display a dialog showing the following information: the bank statement
balance, the amount of uncancelled withdrawals, the difference between the
two (the subtotal), the amount of uncancelled deposits, the addition of the
subtotal and the deposits (the calculated total), the program's current
total, and the difference between the calculated total and the program's
total. This difference should be zero if the entries in the memory and the
bank statement match. If they do not match, the entries in memory are
probably wrong, and should be compared with the bank statement to make sure
the amounts are correct, and that all entries are present. An error message
will appear if the account is unbalanced.
The Options Menu
This menu contains the commands the affect the entries that are
displayed in the search and review windows. They are disabled until the
windows are opened.
Delete Entry - This command will delete an entry from the list. It will
prompt for a verification before deleting, since once the entry is deleted it
is gone forever. If the last entry in memory is deleted, the display window
will close since there are no more entries to display.
Cancel Entry - This command will mark an entry as cancelled. This means
that the entry was found on the bank statement, and that the bank has taken
it into account in calculating the balance on the statement. Since the bank
has taken it into account, the program must also, and this command tells it
to do so. However, an entry can be uncancelled by using the command a second
time, so any errors in cancelling can be repaired.
Edit Entry - This command allows the currently displayed entry to be
edited. A form will open displaying the current data and allowing the user
to change it. The form used is the same one used when the entry was first
entered. Clicking on the "Enter Entry" button will update the changes to
memory, while clicking on the "Quit" button will ignore the changes.
There is a difference between editing entries displayed in the search
window, and editing entries displayed in the review window. In the review
window, when an entry has been edited and entered, the modified entry will be
displayed in the window. In the search window, the window will close after
the entry has been edited. This is because once an entry has been modified,
there is a chance that it no longer follows the search criteria, and
therefore should not be displayed. The list of entries must be searched
again to bring the window back.
Balancing the Checkbook
As briefly describe above, this program will allow the user to balance
his checkbook. The method used to do this is rather simple.
First, enter all of the transactions that occur during the month. Then,
when the bank statement arrives, go through the entries one by one, and check
to see if they appear on the bank statement. If they do, then cancel the
entries using the CANCEL command. After all of the entries have been
checked, select the FIGURE BALANCE command. Enter the ending balance that is
on the statement. The program will show the various amounts used to
determine if the entries in memory match the entries on the bank statement.
If all goes well, they will match and the program will state that the account
is balanced. If there is an error, an error message will be displayed.
If an error occurs, this usually means that one or more of the entries
in memory have invalid amounts, or that an entry is missing. It is possible
that the error is with the bank statement, but this is highly unlikely. The
only thing that can be done is to review the entries, and check the amounts
against the bank statement to insure they are correct. This will usually
solve the problem.
Program Design and Implementation
The program listing is commented well enough so that the logic can be
followed without much trouble. However, there are some design considerations
that were important to the development of the program that may be of some
interest to other programmers, especially those unfamiliar with pointers or
linked lists.
When I first decided to write the program, I wanted to have the entry
list sorted using the date. One of the ways I could have done this is to
have sorted the list after every entry. This would become very time
consuming, so it couldn't be used. I also had a problem in that I didn't
want to allocate a large amount of memory all at once to be used for the
entries, because no matter how large I made the memory block, it would put a
limiting factor on the amount of data that could be entered. For these two
reasons I decided to use a linked list using pointers for holding the data
for the entries. Since pointers were used to link the entries, the entries
could be sorted after every data entry by simply inserting the entry into the
correct place in the list, without having to move the locations of the other
entries. This structure also eliminated the need to allocate a large memory
area, since I could allocate memory for each entry as it was needed, and
deallocated it when the entry was deleted. Thus the linked list structure
was very useful for this implementation.
For those programmers that aren't familiar with linked lists and
pointers, the routines in the program can be very useful. One of the
convenient aspects of using pointers in data representations is that the
algorithms for insertion and deletion into and from a linked list are
standard, and don't have to be modified to be used in a new program. The
algorithms used in this program came from a data structures book,
Fundamentals of Data Structures, by E. Horowitz and S. Sahni. Except for
some additional code unrelated to the linked list that I added, the
algorithms are exactly as they appeared in the book.
A linked list is also used for the search routine. This is because I
needed a fast and easy way to display the entries matching the search
parameters. Searching for the next entry every time an arrow was clicked
would be too time consuming. So I sacrificed some extra memory to generate a
list of the entries that matched the parameters. This list is built during
the "Searching..." message, which is why it doesn't appear on the screen for
very long if the entry list is small (doesn't take much time to search the
entries). Once the list is built, it is a simple matter of displaying them.
After the search window is closed, the entries in the list are deleted, and
the memory is freed. By the way, this same procedure is used in the print
routine.
That's It
That pretty much covers the check balancer program. I tried to put as
much error checking as I could, as well as spending time trying to make sure
everything worked the way it was supposed to work. Hopefully no serious bugs
are hiding in it. I hope you enjoy using it.